<%
=begin
apps: redis, redis-cluster
platforms: kubernetes, tanzu-application-catalog
id: deploy_custom_metrics_script
title: Deploy a custom metrics script in the sidecar
category: administration
weight: 30
highlight: 30
=end %>

A custom Lua script can be added to the *redis-exporter* sidecar by way of the *metrics.extraArgs.script* parameter.  The pathname of the script *MUST* exist on the container, or the *redis_exporter* process (and therefore the whole pod) will refuse to start.  The script can be provided to the sidecar containers via the *metrics.extraVolumes* and *metrics.extraVolumeMounts* parameters:

    metrics:
      extraVolumeMounts:
        - name: '{{ printf "%s-metrics-script-file" (include "common.names.fullname" .) }}'
          mountPath: '{{ printf "/mnt/%s/" (include "common.names.name" .) }}'
          readOnly: true
      extraVolumes:
        - name: '{{ printf "%s-metrics-script-file" (include "common.names.fullname" .) }}'
          configMap:
            name: '{{ printf "%s-metrics-script" (include "common.names.fullname" .) }}'
      extraArgs:
        script: '{{ printf "/mnt/%s/my_custom_metrics.lua" (include "common.names.name" .) }}'

Then deploy the script into the correct location via *extraDeploy*:

    extraDeploy:
      - apiVersion: v1
        kind: ConfigMap
        metadata:
          name: '{{ printf "%s-metrics-script" (include "common.names.fullname" .) }}'
        data:
          my_custom_metrics.lua: |
            -- LUA SCRIPT CODE HERE, e.g.,
            return {'bitnami_makes_the_best_charts', '1'}
